# 
# Created by francklinson on 2021/7/31 AT 21:38.
#
from functools import reduce
from typing import List


class Solution:
    def singleNumber(self, nums: List[int]) -> int:
        ans = 0
        for x in nums:
            ans ^= x
        return ans

    def singleNumber2(self, nums: List[int]) -> int:
        return reduce(lambda x, y: x ^ y, nums)


if __name__ == '__main__':
    sol = Solution()
    print(sol.singleNumber2([2, 2, 1]))
